from django.db import models


# Create your models here.
# 下面这两个分别是爬虫爬下来的数据
from apps.user.models import User


class Medicals(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64, verbose_name='药品名称')

    class Meta:
        db_table = 'medicals'
        verbose_name = '药品存储'

    def __str__(self):
        return self.name


class Medical_loads(models.Model):
    name = models.CharField(max_length=64, verbose_name='药品具体名字', null=True)
    num = models.IntegerField(verbose_name='爬虫顺序', null=True)  # 爬虫爬下来后，是有顺序的，这个就是标记这个顺序
    img_url = models.CharField(max_length=200, verbose_name='图片地址', null=True)
    suit = models.CharField(max_length=1000, verbose_name='适应症状', null=True)
    usemethod = models.CharField(max_length=1000, verbose_name='使用方法', null=True)
    lelment = models.CharField(max_length=200, verbose_name='成分', null=True)
    bad = models.CharField(max_length=1000, verbose_name='不良反应', null=True)
    err = models.CharField(max_length=200, verbose_name='禁忌', null=True)
    heed = models.CharField(max_length=1000, verbose_name='注意事项', null=True)
    savemethod = models.CharField(max_length=200, verbose_name='保存方法', null=True)
    translate = models.IntegerField(verbose_name='收藏标记位', default=0)
    medical = models.ForeignKey(Medicals, on_delete=models.CASCADE, related_name='medical', verbose_name='关联药品')

    class Meta:
        db_table = 'medical_loads'
        verbose_name = '存储的药品们'

    def __str__(self):
        return self.img_url


class User_medicine(models.Model):
    """
    用户购买的药品
    """
    name = models.CharField(max_length=64, verbose_name='药品名称')
    number = models.IntegerField(verbose_name='购买数量')
    message = models.CharField(max_length=200, verbose_name='注意事项', null=True)
    status = models.BooleanField(verbose_name='存储状态')  # 0为已拿走，1为未拿走
    send_data = models.DateField(auto_now=True, verbose_name='发药时间')
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user', verbose_name='药品的主人')

    class Meta:
        db_table = 'user_medicine'
        verbose_name = '用户购买的药品'

    def __str__(self):
        return self.name

# class Medicine_home(models.Model):
#     """药房"""
